
package com.bstek.urule.model.flow;


/**
 * @author Jacky.gao
 * @since 2015年4月20日
 */
public class DecisionItem {
    public static final String RETURN_VALUE_KEY = "return_to__";
    private String script;
    private int percent;//值为1-99
    private String to;

    public String getScript() {
        return script;
    }

    public void setScript(String script) {
        this.script = script;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public int getPercent() {
        return percent;
    }

    public void setPercent(int percent) {
        this.percent = percent;
    }

    public String buildDSLScript(int index) {
        StringBuffer sb = new StringBuffer();
        sb.append("rule \"r" + index + "\"");
        sb.append(" ");
        sb.append("if");
        sb.append(" ");
        sb.append(script);
        sb.append(" ");
        sb.append("then");
        sb.append(" ");
        sb.append("parameter." + RETURN_VALUE_KEY + "=\"" + to + "\"");
        sb.append(" ");
        sb.append("end");
        return sb.toString();
    }
}
